package com.anti.modular.bus.busbasicsettings.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.busbasicsettings.param.BusBasicSettingsParam;
import com.anti.modular.bus.busbasicsettings.service.BusBasicSettingsService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 基础設置表控制器
 *
 * @author anti
 * @date 2021-04-09 10:20:17
 */
@RestController
@RequestMapping("busBasicSettings")
public class BusBasicSettingsController {

    @Resource
    private BusBasicSettingsService busBasicSettingsService;

    /**
     * 查询基础設置表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BusBasicSettingsParam busBasicSettingsParam) {
        return Result.data(busBasicSettingsService.page(pageParam,busBasicSettingsParam));
    }


    @GetMapping("getOne")
    public Result getOne() {
        return Result.data(busBasicSettingsService.getOne());
    }

    /**
     * 添加基础設置表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "基础設置表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusBasicSettingsParam.add.class) BusBasicSettingsParam busBasicSettingsParam) {
            busBasicSettingsService.add(busBasicSettingsParam);
        return Result.success("新增成功");
    }

    /**
     * 删除基础設置表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "基础設置表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusBasicSettingsParam.delete.class) BusBasicSettingsParam busBasicSettingsParam) {
            busBasicSettingsService.delete(busBasicSettingsParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑基础設置表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "基础設置表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusBasicSettingsParam.edit.class) BusBasicSettingsParam busBasicSettingsParam) {
            busBasicSettingsService.edit(busBasicSettingsParam);
        return Result.success("修改成功");
    }

    /**
     * 查看基础設置表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @GetMapping("detail")
    public Result detail(@Validated(BusBasicSettingsParam.detail.class) BusBasicSettingsParam busBasicSettingsParam) {
        return Result.data(busBasicSettingsService.detail(busBasicSettingsParam));
    }

    /**
     * 基础設置表列表
     *
     * @author anti
     * @date 2021-04-09 10:20:17
     */
    @GetMapping("list")
    public Result list(BusBasicSettingsParam busBasicSettingsParam) {
        return Result.data(busBasicSettingsService.list(busBasicSettingsParam));
    }

}
